---
title: Idle Detection
description: Idle Detection feature explanation and example
---

As its namesake suggests, idle detection is the flagship feature of IdleTimer.
The idle detection feature set is responsible for tracking your users activity
based on the events you want to listen to and let you know when the user has 
not triggered those events in a given time period.

### Properties

The properties associated with idle detection are:

{/* cspell:disable */}
- [timeout](/docs/api/props#timeout): The time before a user is considered idle.
- [element](/docs/api/props#element): The DOM element to bind event listeners to.
- [events](/docs/api/props#events): The events to listen for activity on.
- [immediateEvents](/docs/api/props#immediateevents): The events that will immediately trigger an idle event (bypassing timeout).
- [onPresenceChange](/docs/api/props#onpresencechange): Function called when a user's presence state changes.
- [onIdle](/docs/api/props#onidle): Function called when a user becomes idle from an active state.
- [onActive](/docs/api/props#onactive): Function called when a user becomes active from an idle state.
- [eventsThrottle](/docs/api/props#eventsthrottle): Throttle for the events bound. Saves on CPU if you are using repeated events.
- [startOnMount](/docs/api/props#startonmount): Starts the timer when the host component mounts.
- [startManually](/docs/api/props#startmanually): Require a call to `start()` in order to start the timer.
- [stopOnIdle](/docs/api/props#stoponidle): Require the timer to be manually reset after going idle by calling `start()` or `reset()`.
{/* cspell:enable */}

### Methods

The methods associated with idle detection are:

{/* cspell:disable */}
- [start](/docs/api/methods#start): Starts the timer.
- [reset](/docs/api/methods#reset): Resets the timer to its initial state.
- [activate](/docs/api/methods#activate): Resets the IdleTimer instance to its initial state, starts the timer and emits `onActive` if the user was idle.
- [pause](/docs/api/methods#pause): Pauses a running timer.
- [resume](/docs/api/methods#resume): Resumes a running timer.
- [getElapsedTime](/docs/api/methods#getelapsedtime): Returns the time in milliseconds since the host component was mounted.
- [getRemainingTime](/docs/api/methods#getremainingtime): Returns the time remaining in milliseconds until idle.
- [getLastActiveTime](/docs/api/methods#getlastactivetime): Returns a Date of the last time the user was active.
- [getActiveTime](/docs/api/methods#getactivetime): Returns time in milliseconds the user was active since the last reset.
- [getTotalActiveTime](/docs/api/methods#gettotalactivetime): Returns time in milliseconds the user was active since the component mounted.
- [getLastIdleTime](/docs/api/methods#getlastidletime): Returns a Date of the last time the user was idle.
- [getIdleTime](/docs/api/methods#getidletime): Returns time in milliseconds the user was idle since the last reset.
- [getTotalIdleTime](/docs/api/methods#gettotalidletime): Returns time in milliseconds the user was idle since the component mounted.
{/* cspell:enable */}

### Example
<CodeSandbox name='idle-timer-hook-03790m' />